/*
 * @Descripttion: 
 * @version: 
 * @Author: 
 * @Date: 2020-08-24 14:18:18
 * @LastEditors: 穆宏宇
 * @LastEditTime: 2020-09-22 11:55:09
 */
import tools from '@/tools'
// import allRouter from '@/router/router.all'

export default {
  state: {
    // menuList: tools.localRead('menuList') ? tools.localRead('menuList').split(',') : [],
    // routerUpdated: 0

  },
  getters: {
    menuList: (state, getters) => tools.getMenuByRouter(getters.routerList),
    // menuList: () => tools.getMenuByRouter(allRouter[2].children),
    routerList: state => {
      state.routerUpdated = 1
      // const routerList = JSON.parse(tools.localRead('routerList'))
      const routerList = [  
        {
          path: '/biaozhun/dizhi',
          name: '标准地址管理',
          meta: {
            show: true
          }
        },
        {
          path: '/organization',
          name: '组织机构管理',
          meta: {
            show: true
          }
        },
      ]
      // return tools.routerEach(routerList)
      return []
    }
  },
  mutations: {
    setMenuList (state) {
      const arr = tools.getMenuByRouter(state.routerList)
      const str = arr && arr.length > 0 ? arr.join(',') : ''
      tools.localSave('menuList', str)

      state.menuList = arr
    },
    setRouterList (state, routerList = []) {
      tools.localSave('routerList', JSON.stringify(routerList))
      // const arr = tools.routerEach(routerList)
      // console.log(arr)
      // state.routerList = arr
      // state.routerUpdated = 1
    }
  },
  actions: {}
}
